layui.define(['jquery','form', 'element', 'YsModal'], function (exports) {
	"use strict";
	var $ = layui.jquery,form=layui.form,object = {
		c: {data:[]}, // 配置项
		f: function (c) { // 数据初始化
			var s=new Date().getTime(),t = this;
			t.c.id = c.id?c.id:'simple_table_THR_OperateCompanyApply_ByArchives';
			t.c.tableId = c.tableelem?c.tableelem:'table-'+s;
			t.c.id_tab_1 = 'id_tab_1_'+s;
			t.c.id_tab_2 = 'id_tab_2_' + s;
			t.c.id_tab_3 = 'id_tab_3_' + s;
			t.c.id_grid_1 = 'id_grid_1_' + s;
			t.c.id_grid_2 = 'id_grid_2_' + s;
			t.c.id_grid_3 = 'id_grid_3_' + s;
			t.c.data = c.data; // 运营公司表VPS信息
			t.c.data2 = c.data2; // 运营公司表品牌信息
			t.c.data3 = c.data3; // 运营公司表欧洲贸易合规
			t.c.vgsbm = c.vgsbm;
			t.c.vgsjc = c.vgsjc;
			
			/**自定义的字段，是否流转中**/
			t.c.onProcess = c.onProcess;
			t.c.onProcessBySon = c.onProcessBySon;

			//复选框选中，存放行号，表1
			t.c.checkedIndex_1 = [];
			t.c.checkedIndex_2 = [];
			t.c.checkedIndex_3 = [];

			//多文件上传需要
			t.c.id_form_1 = 'id_form_1_' + s;
			t.c.id_form_2 = 'id_form_2_' + s;
			t.c.id_form_3 = 'id_form_3_' + s;
			t.c.urlUpload = 'https://file.mini-ease.com/api/outer/upload/uploadForERP_1_0';
		},
		load:function () { // 加载控件
			var h = ``
				+ `<div class="layui-tab layui-tab-brief" style="background-color: #ffffff;padding-top: 10px;padding-bottom: 10px;">`
					+ `<ul class="layui-tab-title">`
						+ `<li class="layui-this">1、VPS信息</li>`
						+ `<li>2、品牌信息</li>`
						+ `<li>3、欧洲贸易合规信息</li>`
					+ `</ul>`

					+ `<div class="layui-tab-content">`
						+ `<div class="layui-tab-item layui-show">`
							+ `<div class="layui-table-tool" style="padding: 0; min-height: 0; background-color: #ffffff;" id="` + this.c.id_tab_1 + `">`
								+ `<div class="layui-table-tool-temp">`;
								if (this.c.onProcessBySon == 0 && this.c.onProcess == 0) {
									h+=`<div class="layui-btn-container" style="padding-bottom: 10px;padding-left: 10px;">`
										+ `<a class="layui-btn layui-btn-normal layui-btn-sm " lay-event="event-to-add-1"><i class="iconfont icon-add-btn"></i>新增</a>`
										+ `<a class="layui-btn layui-btn-danger layui-btn-sm " lay-event="event-to-del-1" ><i class="layui-icon layui-icon-delete"></i>删除</a>`
									+ `</div>`;
								}
								h+= `<div class="layui-form layui-form-item" id="` + this.c.id_form_1 + `"  pane>`
										+ `<div id="` + this.c.id_grid_1 + `">`
											+ this.loadTable()
										+ `</div>`
									+ `</div>`
								+ `</div>`
							+ `</div>`
						+ `</div>`
						+ `<div class="layui-tab-item">`
							+ `<div class="layui-table-tool" style="padding: 0; min-height: 0; background-color: #ffffff;" id="` + this.c.id_tab_2 + `">`
								+ `<div class="layui-table-tool-temp" style="padding-right: 0;">`;
								if (this.c.onProcessBySon == 0 && this.c.onProcess == 0) {
									h+= `<div class="layui-btn-container" style="padding-bottom: 10px;padding-left: 10px;">`
										+ `<a class="layui-btn layui-btn-normal layui-btn-sm " lay-event="event-to-add-2"><i class="iconfont icon-add-btn"></i>新增</a>`
										+ `<a class="layui-btn layui-btn-danger layui-btn-sm " lay-event="event-to-del-2" ><i class="layui-icon layui-icon-delete"></i>删除</a>`
									+ `</div>`;
								}
									h+= `<div class="layui-form layui-form-item" id="` + this.c.id_form_2 + `" pane>`
										+ `<div id="` + this.c.id_grid_2 + `">`
											+ this.loadGrid_2()
										+ `</div>`
									+ `</div>`
								+ `</div>`
							+ `</div>`
						+ `</div>`
						+ `<div class="layui-tab-item">`
							+ `<div class="layui-table-tool" style="padding: 0; min-height: 0; background-color: #ffffff;" id="` + this.c.id_tab_3 + `">`
								+ `<div class="layui-table-tool-temp" style="padding-right: 0;">`;
							if (this.c.onProcessBySon == 0 && this.c.onProcess == 0) {
								h+= `<div class="layui-btn-container" style="padding-bottom: 10px;padding-left: 10px;">`
									+ `<a class="layui-btn layui-btn-normal layui-btn-sm " lay-event="event-to-add-3"><i class="iconfont icon-add-btn"></i>新增</a>`
									+ `<a class="layui-btn layui-btn-danger layui-btn-sm " lay-event="event-to-del-3" ><i class="layui-icon layui-icon-delete"></i>删除</a>`
								+ `</div>`;
							}
								h+= `<div class="layui-form layui-form-item" id="` + this.c.id_form_3 + `" pane>`
									+ `<div id="` + this.c.id_grid_3 + `">`
										+ this.loadGrid_3()
									+ `</div>`
									+ `</div>`
								+ `</div>`
							+ `</div>`
						+ `</div>`
					+ `</div>`
				+ `</div>`;
			$('#'+this.c.id).html(h);
			this.listenAll();
		},
		loadTable:function () { // 加载表格
			return ``
			+ `<div class="layui-table-box">`
				+ `<div class="layui-table-header" style="height: 300px; max-height: 300px; overflow: auto; background-color: #ffffff;">`
					+ `<table cellspacing="0" cellpadding="0" border="0" class="layui-table" lay-skin="grid" lay-even="" style="margin: 0;">`
						+ `<thead>`
							+ this.loadTableOfThead()
						+ `</thead>`
						+ `<tbody>` + this.loadTableOfTbody()+`</tbody>`
					+ `</table>`
				+ `</div>`
			+ `</div>`;
		},
		loadTableOfThead:function () { // 加载表头
			var h = `<thead>`;
			h +=`<tr>`;
			if(this.c.onProcessBySon == 0 && this.c.onProcess == 0) {//可编辑
				h += `<th style="width:1.9%; text-align: center; color: #000000;padding: 0 !important;">
							<input type="checkbox" id="checkAll" lay-skin="primary" lay-filter="checkAll">
						</th>`;
			}
			h += `<th style="width:5%; text-align: center; color: #000000;">运营公司编码</th>`;
			h += `<th style="width:5%; text-align: center; color: #000000;">运营公司简称</th>`;
			h += `<th style="width:5%; text-align: center; color: #000000;">配置</th>`;
			h += `<th style="width:5%; text-align: center; color: #000000;">年费标准</th>`;
			h += `<th style="width:5%; text-align: center; color: #000000;">IP</th>`;
			h += `<th style="width:5%; text-align: center; color: #000000;">户名</th>`;
			h += `<th style="width:5%; text-align: center; color: #000000;">初始密码</th>`;
			h += `<th style="width:5%; text-align: center; color: #000000;">云平台</th>`;
			h += `<th style="width:5%; text-align: center; color: #000000;">备注</th>`;
			h += `<th style="width:5%; text-align: center; color: #000000;">创建时间</th>`;

			h + `</thead>`;
			return h;
		},
		loadTableOfTbody:function () { // 加载表tbody
			var t = this;
			var h = `<tbody id="tbody">`;
			for(var i=0;i<t.c.data.length;i++){
				h += `<tr id="table_th_`+i+`">`;
				h += t.loadTableTdOfTbody(t.c.data[i],i);
				h+= `</tr>`;
			}
			h += `</tbody>`;
			return h;
		},
		loadTableTdOfTbody:function (data,i) { // 加载表格行
			var h = ``;
			if(this.c.onProcessBySon == 0 && this.c.onProcess == 0) {//可编辑
				h += `<td style="text-align:center;padding:0;">
					<input type="checkbox" class="chBox"  lay-skin="primary" data-index="` + i + `"  lay-filter="checkBoxOne">
					</td>`;
			}
			h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;">` + data.vgsbm + `</td>`;
			h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;">` + data.vgsjc + `</td>`;
			if(this.c.onProcessBySon == 0 && this.c.onProcess == 0) {//可编辑
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" maxlength="50"  class="text_align_center layui-input" data-index="` + i + `" data-type="configureInfo" lay-filter="_input"  value="` + (data.configureInfo ? data.configureInfo : ``) + `" ></td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="number" maxlength="10" class="text_align_center layui-input" data-index="` + i + `" data-type="annualFee" lay-filter="_input"  value="` + (data.annualFee ? data.annualFee : ``) + `" ></td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" maxlength="20" class="text_align_center layui-input" data-index="` + i + `" data-type="ipInfo" lay-filter="_input"  value="` + (data.ipInfo ? data.ipInfo : ``) + `" ></td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" maxlength="20" class="text_align_center layui-input" data-index="` + i + `" data-type="accountName" lay-filter="_input"  value="` + (data.accountName ? data.accountName : ``) + `" ></td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" maxlength="20" class="text_align_center layui-input" data-index="` + i + `" data-type="accountPwd" lay-filter="_input"  value="` + (data.accountPwd ? data.accountPwd : ``) + `" ></td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" maxlength="20" class="text_align_center layui-input" data-index="` + i + `" data-type="cloudPlatform" lay-filter="_input"  value="` + (data.cloudPlatform ? data.cloudPlatform : ``) + `" ></td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" maxlength="200" class="text_align_center layui-input" data-index="` + i + `" data-type="remark" lay-filter="_input"  value="` + (data.remark ? data.remark : ``) + `" ></td>`;
			}else {
				h += `<td style="text-align:center; padding: 0;">` + data.configureInfo + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + data.annualFee + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + data.ipInfo + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + data.accountName + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + data.accountPwd + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + data.cloudPlatform + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + data.remark + `</td>`;
			}
			h += `<td style="text-align:center; padding: 0;">` + (data.createTime ? data.createTime.substring(0, 10): '') + `</td>`;
			return h;
		},
		loadGrid_2:function () { // 加载表格
			return `<table class="layui-table" lay-skin="row" style="margin:0;"><thead>`+this.loadGrid_2_OfThead()+`</thead><tbody>`+this.loadGrid_2_OfTbody()+`</tbody></table>`;
		},
		reloadGrid_2:function () { // 重新加载第二张表格
			$('#'+this.c.id_grid_2).html(this.loadGrid_2());
			this.listenGrid_2();
		},
		loadGrid_2_OfThead:function () { // 加载表头
			var h = `<thead><tr>`;
			if(this.c.onProcessBySon == 0 && this.c.onProcess == 0) {//可编辑
				h += `<th style="width:1.9%; text-align: center; color: #000000;padding: 0 !important;">
							<input type="checkbox" id="checkAll_2" lay-skin="primary" lay-filter="checkAll_2">
						</th>`;
			}
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">运营公司编码</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">运营公司简称</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">国家</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">品牌名</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">品牌状态</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">附件</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">创建时间</th>`;
			return h;
		},
		loadGrid_2_OfTbody:function () { // 加载表tbody
			var t = this;
			var h = `<tbody id="tbody_2">`;
			for(var i=0;i<t.c.data2.length;i++){
				h += `<tr id="table_2_th_`+i+`">`;
				h += t.loadTableTdOfTbody_2(t.c.data2[i],i);
				h+= `</tr>`;
			}
			h += `</tbody>`;
			return h;
		},
		loadTableTdOfTbody_2:function (data,i) { // 加载表格行
			var h = ``;
			if(this.c.onProcessBySon == 0 && this.c.onProcess == 0) {//可编辑
				h += `<td style="text-align:center;padding:0;">
					<input type="checkbox" class="chBox_2"  lay-skin="primary" data-index="` + i + `"  lay-filter="checkBoxOne_2">
					</td>`;
			}
			h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;">` + data.vgsbm + `</td>`;
			h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;">` + data.vgsjc + `</td>`;
			if(this.c.onProcessBySon == 0 && this.c.onProcess == 0) {//可编辑
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" class="layui-input" value="` + (data.countryName ? data.countryName : '') + `" readonly="readonly"><i style="position: absolute; right: 2px; top:0px; height: 30px; line-height: 30px; width: 25px;" class="layui-icon layui-icon-more" data-type="countryName" data-index="` + i + `" lay-filter="buttontextModelByCountryName"></i></td>`;
				//h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" class="layui-input" value="` + (data.countryName ? data.countryName : '') + `" readonly="readonly"><i style="position: absolute; right: 2px; top:0px; height: 30px; line-height: 30px; width: 25px;" class="layui-icon layui-icon-more" data-type="countryName" data-index="` + i + `" lay-filter="buttontextModelByCountryName"></i></td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" maxlength="20" class="text_align_center layui-input" data-index="` + i + `" data-type="brandName" lay-filter="_input"  value="` + (data.brandName ? data.brandName : ``) + `" ></td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" maxlength="20" class="text_align_center layui-input" data-index="` + i + `" data-type="brandStatus" lay-filter="_input"  value="` + (data.brandStatus ? data.brandStatus : ``) + `" ></td>`;

			}else {
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;">` + data.countryName + `</td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;">` + data.brandName + `</td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;">` + data.brandStatus + `</td>`;
			}
			//多文件上传
			h +='<td style="width:8%;text-align:center;padding:0;">' +
				'<input type="text"  data-index="' + i + '" value="' + (data.otherFile?data.otherFile : '0个附件') + '" autocomplete="off" class="layui-input height_30 height_30 cannot_edit" readonly data-filter="_filter_input_file_multy_son" data-source-son="2" data-source-code="otherFile" data-source-type="20" data-source-id="' + data.id + '">'+
				'</td>';
			h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;">` + (data.createTime ? data.createTime.substring(0, 10): '') + `</td>`;
			return h;
		},

		//第三张表格相关
		loadGrid_3:function () { // 加载表格
			return `<table class="layui-table" lay-skin="row" style="margin:0;"><thead>`+this.loadGrid_3_OfThead()+`</thead><tbody>`+this.loadGrid_3_OfTbody()+`</tbody></table>`;
		},
		reloadGrid_3:function () { // 重新加载第三张表格
			$('#'+this.c.id_grid_3).html(this.loadGrid_3());
			this.listenGrid_3();
		},
		loadGrid_3_OfThead:function () { // 加载表头
			var h = `<thead><tr>`;
			if(this.c.onProcessBySon == 0 && this.c.onProcess == 0) {//可编辑
				h += `<th style="width:1.9%; text-align: center; color: #000000;padding: 0 !important;">
							<input type="checkbox" id="checkAll_3" lay-skin="primary" lay-filter="checkAll_3">
						</th>`;
			}
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">运营公司编码</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">运营公司简称</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">国家</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">VAT号</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">MTD码</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">VAT申报方式</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">VAT申报周期开始月份</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">VAT通过时间</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">EORI国家</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">EORI码</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">EORI通过时间</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">包装法注册号</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">包装法通过时间</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">附件</th>`;
			h += `<th style="width:8%; text-align: center;color: #000000;padding: 0 !important;">备注</th>`;
			return h;
		},
		loadGrid_3_OfTbody:function () { // 加载表tbody
			var t = this;
			var h = `<tbody id="tbody_3">`;
			for(var i=0;i<t.c.data3.length;i++){
				h += `<tr id="table_3_th_`+i+`">`;
				h += t.loadTableTdOfTbody_3(t.c.data3[i],i);
				h+= `</tr>`;
			}

			h += `</tbody>`;
			return h;
		},
		loadTableTdOfTbody_3:function (data,i) { // 加载表格行
			var h = ``;
			if(this.c.onProcessBySon == 0 && this.c.onProcess == 0) {//可编辑
				h += `<td style="text-align:center;padding:0;">
					<input type="checkbox" class="chBox_3"  lay-skin="primary" data-index="` + i + `"  lay-filter="checkBoxOne_3">
					</td>`;
			}
			h += `<td style="text-align:center;width:8%;padding: 0 !important;border-width: 1px;">` + data.vgsbm + `</td>`;
			h += `<td style="text-align:center;width:8%;padding: 0 !important;border-width: 1px;">` + data.vgsjc + `</td>`;
			if(this.c.onProcessBySon == 0 && this.c.onProcess == 0) {//可编辑
				h += `<td style="text-align:center;	width:8%;padding: 0 !important;border-width: 1px;"><input type="text" class="layui-input" value="` + (data.countryName ? data.countryName : '') + `" readonly="readonly"><i style="position: absolute; right: 2px; top:0px; height: 30px; line-height: 30px; width: 25px;" class="layui-icon layui-icon-more" data-type="countryName" data-index="` + i + `" lay-filter="buttontextModelByCountryName2"></i></td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" maxlength="20" class="text_align_center layui-input" data-index="` + i + `" data-type="vatNo" lay-filter="_input"  value="` + (data.vatNo ? data.vatNo : ``) + `" ></td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" maxlength="20" class="text_align_center layui-input" data-index="` + i + `" data-type="mtdCode" lay-filter="_input"  value="` + (data.mtdCode ? data.mtdCode : ``) + `" ></td>`;
				h += `<td style="text-align:center; padding: 0;">`
					+ `<select id="vatType" style="text-align: center" name="vatType"  lay-filter="buttontextModelSel"  data-type="vatType"` + `data-index="` + i + `">`;
				h += `<option value="" >请选择</option>
								<option value="0" `+(data.vatType == '0'?`selected`:``)+`>按月</option>
								<option value="1" `+(data.vatType == '1'?`selected`:``)+`>按季度</option>
								<option value="2" `+(data.vatType == '2'?`selected`:``)+`>按年</option>`;
				h +=`</select>`+
					`</td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;">`;
				h+= `<input type="text" class="layui-input vatDeclareStart" data-index="` + i + `" value="` + (data.vatDeclareStart ? data.vatDeclareStart: '') + `" readonly="readonly">` +
					`<i class="layui-icon layui-icon-date vatDeclareStart" id="vatDeclareStart` + i + `" data-index="` + i + `" lay-event="event-to-chooseDataTime" style="position: absolute; right: 2px; top:4px; height: 30px; line-height: 30px; width: 25px;"></i>`;
				h +=`</td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;">`;
				h+= `<input type="text" class="layui-input vatPassTime" data-index="` + i + `" value="` + (data.vatPassTime ? data.vatPassTime.substring(0, 10): '') + `" readonly="readonly">` +
					`<i class="layui-icon layui-icon-date vatPassTime" id="vatPassTime` + i + `" data-index="` + i + `" lay-event="event-to-chooseDataTime" style="position: absolute; right: 2px; top:4px; height: 30px; line-height: 30px; width: 25px;"></i>`;
				h +=`</td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" class="layui-input" value="` + (data.eoriCountryName ? data.eoriCountryName : '') + `" readonly="readonly"><i style="position: absolute; right: 2px; top:0px; height: 30px; line-height: 30px; width: 25px;" class="layui-icon layui-icon-more" data-type="eoriCountryName" data-index="` + i + `" lay-filter="buttontextModelByCountryName3"></i></td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" maxlength="20" class="text_align_center layui-input" data-index="` + i + `" data-type="eoriCode" lay-filter="_input"  value="` + (data.eoriCode ? data.eoriCode : ``) + `" ></td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;">`;
				h+= `<input type="text" class="layui-input eoriPassTime" data-index="` + i + `" value="` + (data.eoriPassTime ? data.eoriPassTime.substring(0, 10) : '') + `" readonly="readonly">` +
					`<i class="layui-icon layui-icon-date eoriPassTime" id="eoriPassTime` + i + `" data-index="` + i + `" lay-event="event-to-chooseDataTime" style="position: absolute; right: 2px; top:4px; height: 30px; line-height: 30px; width: 25px;"></i>`;
				h +=`</td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" maxlength="20" class="text_align_center layui-input" data-index="` + i + `" data-type="packRegisterNo" lay-filter="_input"  value="` + (data.packRegisterNo ? data.packRegisterNo : ``) + `" ></td>`;
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;">`;
				h+= `<input type="text" class="layui-input packPassTime" data-index="` + i + `" value="` + (data.packPassTime ? data.packPassTime.substring(0, 10) : '') + `" readonly="readonly">` +
					`<i class="layui-icon layui-icon-date packPassTime" id="packPassTime` + i + `" data-index="` + i + `" lay-event="event-to-chooseDataTime" style="position: absolute; right: 2px; top:4px; height: 30px; line-height: 30px; width: 25px;"></i>`;
				h +=`</td>`;
			}else {
				var vatTypeTxt = '';
				if(data.vatType!=undefined && data.vatType!=null) {
					if(data.vatType==0){
						vatTypeTxt = '按月';
					}else if(data.vatType==1){
						vatTypeTxt = '按季度';
					}else if(data.vatType==2){
						vatTypeTxt = '按年';
					}
				}
				h += `<td style="text-align:center; padding: 0;">` + data.countryName + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + data.vatNo + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + data.mtdCode + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + vatTypeTxt + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + data.vatDeclareStart + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + (data.vatPassTime ? data.vatPassTime.substring(0, 10): '') + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + data.eoriCountryName + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + data.eoriCode + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + (data.eoriPassTime ? data.eoriPassTime.substring(0, 10): '') + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + data.packRegisterNo + `</td>`;
				h += `<td style="text-align:center; padding: 0;">` + (data.packPassTime ? data.packPassTime.substring(0, 10): '') + `</td>`;
			}
			//多文件上传
			h +='<td style="width:8%;text-align:center;padding: 0 !important;border-width: 1px;">' +
				'<input type="text"  data-index="' + i + '" value="' + (data.otherFile?data.otherFile : '0个附件') + '" autocomplete="off" class="layui-input height_30 height_30 cannot_edit" readonly data-filter="_filter_input_file_multy_son" data-source-son="3 data-source-code="otherFile" data-source-type="21" data-source-id="' + data.id + '">'+
				'</td>';
			if(this.c.onProcessBySon == 0 && this.c.onProcess == 0) {//可编辑
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;"><input type="text" maxlength="200" class="text_align_center layui-input" data-index="` + i + `" data-type="remark" lay-filter="_input"  value="` + (data.remark ? data.remark : ``) + `" ></td>`;
			}else{
				h += `<td style="text-align:center; width:8%;padding: 0 !important;border-width: 1px;">` + data.remark + `</td>`;
			}
			return h;
		},

		listenAll:function () { // 添加监听
			var t = this;
			// 监听标签页1
			t.listenTab_1();
			// 监听标签页2
			t.listenTab_2();
			// 监听标签页3
			t.listenTab_3();
			// 表单控件重新加载
			form.render();
		},
		listenTab_1:function () { // 添加监听1
			var t = this;

			var domTab = $('#' + t.c.id_tab_1);

			// 监听“新增”按钮
			domTab.find('a[lay-event="event-to-add-1"]').on('click',function (e) {
				var rowCurrent = {};
				rowCurrent.id = null;
				rowCurrent.vgsbm = t.c.vgsbm;
				rowCurrent.vgsjc = t.c.vgsjc;
				rowCurrent.configureInfo = '';
				rowCurrent.annualFee = 0;
				rowCurrent.ipInfo = '';
				rowCurrent.accountName = '';
				rowCurrent.accountPwd = '';
				rowCurrent.cloudPlatform = '';
				rowCurrent.remark = '';
				rowCurrent.createTime = '';
				t.addRow(rowCurrent);
			});

			// 监听“删除”按钮
			$('a[lay-event="event-to-del-1"]').on('click',function (e) {
				var checkedIndexList = t.c.checkedIndex_1;
				if (checkedIndexList.length ==0 || checkedIndexList==null){
					return layer.msg("请至少选择一条要删除的数据!");
				}
				var oldData = [];
				for (var i = 0; i < t.c.data.length; i++) {
					for (var j = 0; j < checkedIndexList.length; j++) {
						if(i == checkedIndexList[j]){
							oldData.push(t.c.data[i].id);
						}
					}
				}
				if(oldData.length>0){
					t.delYes(oldData,checkedIndexList,1);
				}
			}),

			//全选
			layui.form.on('checkbox(checkAll)', function(data){
				var elem = data.elem;
				$(".chBox").prop("checked", elem.checked);
				var checkedIndex = [];
				$(".chBox").each(function(k, v){
					if ($(v).is(':checked')) {
						checkedIndex.push($(v).attr('data-index'));
					}
				});
				t.c.checkedIndex_1 = checkedIndex;
				layui.form.render();
			});
			// 列表里的小选择框点击
			layui.form.on('checkbox(checkBoxOne)', function(data){
				var elem = data.elem;
				//console.log('elem',elem);
				if ($(".chBox").not('input:checked').length) {
					$('#checkAll').prop("checked", false);
				} else {
					$('#checkAll').prop("checked", true);
				}
				var checkedIndex = [];
				$(".chBox").each(function(k, v){
					if ($(v).is(':checked')) {
						checkedIndex.push($(v).attr('data-index'));
					}
				});
				t.c.checkedIndex_1 = checkedIndex;
				layui.form.render();
			});

			t.listenGrid_1();
		},
		listenTab_2:function () { // 添加监听2
			var t = this;
			var domTab = $('#' + t.c.id_tab_2);

			// 监听“新增”按钮
			domTab.find('a[lay-event="event-to-add-2"]').on('click',function (e) {
				var rowCurrent = {};
				rowCurrent.id = null;
				rowCurrent.vgsbm = t.c.vgsbm;
				rowCurrent.vgsjc = t.c.vgsjc;
				rowCurrent.amazonRegionItemId = '';
				rowCurrent.countryName = '';
				rowCurrent.brandName = '';
				rowCurrent.brandStatus = '';
				rowCurrent.otherFile = '0个附件';
				rowCurrent.createTime = '';
				rowCurrent.countryCode = '';
				t.addRow2(rowCurrent);
			});

			// 监听“删除”按钮
			$('a[lay-event="event-to-del-2"]').on('click',function (e) {
				var checkedIndexList = t.c.checkedIndex_2;
				if (checkedIndexList.length ==0 || checkedIndexList==null){
					return layer.msg("请至少选择一条要删除的数据!");
				}
				var oldData = [];
				for (var i = 0; i < t.c.data2.length; i++) {
					for (var j = 0; j < checkedIndexList.length; j++) {
						if(i == checkedIndexList[j]){
							oldData.push(t.c.data2[i].id);
						}
					}
				}
				if(oldData.length>0){
					t.delYes(oldData,checkedIndexList,2);
				}
			}),


			//全选
			layui.form.on('checkbox(checkAll_2)', function(data){
				var elem = data.elem;
				$(".chBox_2").prop("checked", elem.checked);
				var checkedIndex = [];
				$(".chBox_2").each(function(k, v){
					if ($(v).is(':checked')) {
						checkedIndex.push($(v).attr('data-index'));
					}
				});
				t.c.checkedIndex_2 = checkedIndex;
				layui.form.render();
			});
			
			// 列表里的小选择框点击
			layui.form.on('checkbox(checkBoxOne_2)', function(data){
				var elem = data.elem;
				if ($(".chBox_2").not('input:checked').length) {
					$('#checkAll_2').prop("checked", false);
				} else {
					$('#checkAll_2').prop("checked", true);
				}
				var checkedIndex = [];
				$(".chBox_2").each(function(k, v){
					if ($(v).is(':checked')) {
						checkedIndex.push($(v).attr('data-index'));
					}
				});
				t.c.checkedIndex_2 = checkedIndex;
				layui.form.render();
			});
			t.listenGrid_2();
		},
		listenTab_3:function () { // 添加监听3
			var t = this;
			var domTab = $('#' + t.c.id_tab_3);

			// 监听“新增”按钮
			domTab.find('a[lay-event="event-to-add-3"]').on('click',function (e) {
				var rowCurrent = {};
				rowCurrent.id = null;
				rowCurrent.vgsbm = t.c.vgsbm;
				rowCurrent.vgsjc = t.c.vgsjc;
				rowCurrent.countryCode = '';
				rowCurrent.countryName = '';
				rowCurrent.vatNo = '';
				rowCurrent.mtdCode = '';
				rowCurrent.vatType = '';
				rowCurrent.vatPassTime = '';
				rowCurrent.vatDeclareStart = '';
				rowCurrent.eoriRegionItemId = '';
				rowCurrent.eoriCountryCode = '';
				rowCurrent.eoriCountryName = '';
				rowCurrent.eoriCode = '';
				rowCurrent.eoriPassTime = '';
				rowCurrent.packRegisterNo = '';
				rowCurrent.packPassTime = '';
				rowCurrent.otherFile = '0个附件';
				rowCurrent.remark = '';
				t.addRow3(rowCurrent);
			});

			// 监听“删除”按钮
			$('a[lay-event="event-to-del-3"]').on('click',function (e) {
				var checkedIndexList = t.c.checkedIndex_3;
				if (checkedIndexList.length ==0 || checkedIndexList==null){
					return layer.msg("请至少选择一条要删除的数据!");
				}
				var oldData = [];
				for (var i = 0; i < t.c.data3.length; i++) {
					for (var j = 0; j < checkedIndexList.length; j++) {
						if(i == checkedIndexList[j]){
							oldData.push(t.c.data3[i].id);
						}
					}
				}
				if(oldData.length>0){
					t.delYes(oldData,checkedIndexList,3);
				}
			}),

			//全选
			layui.form.on('checkbox(checkAll_3)', function(data){
				var elem = data.elem;
				$(".chBox_3").prop("checked", elem.checked);
				var checkedIndex = [];
				$(".chBox_3").each(function(k, v){
					if ($(v).is(':checked')) {
						checkedIndex.push($(v).attr('data-index'));
					}
				});
				t.c.checkedIndex_3 = checkedIndex;
				layui.form.render();
			});

			// 列表里的小选择框点击
			layui.form.on('checkbox(checkBoxOne_3)', function(data){
				var elem = data.elem;
				if ($(".chBox_3").not('input:checked').length) {
					$('#checkAll_3').prop("checked", false);
				} else {
					$('#checkAll_3').prop("checked", true);
				}
				var checkedIndex = [];
				$(".chBox_3").each(function(k, v){
					if ($(v).is(':checked')) {
						checkedIndex.push($(v).attr('data-index'));
					}
				});
				t.c.checkedIndex_3 = checkedIndex;
				layui.form.render();
			});
			t.listenGrid_3();
		},

		listenGrid_1:function () { // 添加表格监听1
			var t = this;
			var domGrid = $('#' + t.c.id_grid_1);

			//先移除监听、再添加监听
			//$("input").off("click");
			domGrid.find('input[lay-filter="_input"]').off("click");
			// 监听各个输入框
			domGrid.find('input[lay-filter="_input"]').on('change',function (e) {
				var index = $(this).attr('data-index');
				var key = $(this).attr('data-type');
				var value = $(this).val();
				t.c.data[index][key] = value;
				return;
			});

			//多文件上传
			t.listenFormOfFileMultyBySon(1);
			// 表单控件重新加载
			form.render();
		},
		listenGrid_2:function () { // 添加表格监听2
			var t = this;
			var domGrid = $('#' + t.c.id_grid_2);

			//先移除监听、再添加监听
			//$("input").off("click");
			domGrid.find('input[lay-filter="_input"]').off("click");
			// 监听各个输入框
			domGrid.find('input[lay-filter="_input"]').on('change',function (e) {
				var index = $(this).attr('data-index');
				var key = $(this).attr('data-type');
				var value = $(this).val();
				t.c.data2[index][key] = value;
				return;
			});

			domGrid.find('i[lay-filter="buttontextModelByCountryName"]').off("click");
			// 监听弹出框
			domGrid.find('i[lay-filter="buttontextModelByCountryName"]').on('click',function (e) {
				var indexOfRow = $(this).attr('data-index');
				layui.YsModal.init({modalKey: 'TB_Country', colCode: indexOfRow, parentObj: t, extraData: {useIn: 'countryNameByBrand'}});
			});


			//多文件上传
			t.listenFormOfFileMultyBySon(2);
			// 表单控件重新加载
			form.render();
		},
		listenGrid_3:function () { // 添加表格监听3
			var t = this;
			var domGrid = $('#' + t.c.id_grid_3);

			//先移除监听、再添加监听
			//$("input").off("click");
			domGrid.find('input[lay-filter="_input"]').off("click");
			// 监听各个输入框
			domGrid.find('input[lay-filter="_input"]').on('change',function (e) {
				var index = $(this).attr('data-index');
				var key = $(this).attr('data-type');
				var value = $(this).val();
				t.c.data3[index][key] = value;
				return;
			});
			//先移除监听、再添加监听
			//$("i").off("click");
			domGrid.find('i[lay-filter="buttontextModelByCountryName2"]').off("click");
			domGrid.find('i[lay-filter="buttontextModelByCountryName3"]').off("click");
			// 监听弹出框
			domGrid.find('i[lay-filter="buttontextModelByCountryName2"]').on('click',function (e) {
				var indexOfRow = $(this).attr('data-index');
				layui.YsModal.init({modalKey: 'TB_Country', colCode: indexOfRow, parentObj: t, extraData: {useIn: 'chooseCountryName2'}});
			});
			// 监听弹出框
			domGrid.find('i[lay-filter="buttontextModelByCountryName3"]').on('click',function (e) {
				var indexOfRow = $(this).attr('data-index');
				layui.YsModal.init({modalKey: 'TB_Country', colCode: indexOfRow, parentObj: t, extraData: {useIn: 'chooseCountryName3'}});
			});

			// 绑定选择框(转换)的值变化提交事件
			layui.form.on('select(buttontextModelSel)', function(data){
				var indexOfRow = $(data.elem).attr('data-index');
				t.c.data3[indexOfRow].vatType = data.value;
			});

			//监听时间选择
			layui.laydate.render({
				elem: '.vatPassTime',
				type: 'date',
				done: function(value, date, endDate){
					var indexOfRow =  $(this.elem).attr('data-index');
					t.c.data3[indexOfRow].vatPassTime = value;
					var h = t.loadTableTdOfTbody_3(t.c.data3[Number(indexOfRow)],Number(indexOfRow));
					$('#table_3_th_' + indexOfRow).html(h);
					t.listenGrid_3();
				}
			});

			//监听时间选择
			layui.laydate.render({
				elem: '.vatDeclareStart',
				type: 'month',
				done: function(value, date, endDate){
					var indexOfRow =  $(this.elem).attr('data-index');
					t.c.data3[indexOfRow].vatDeclareStart = value;
					var h = t.loadTableTdOfTbody_3(t.c.data3[Number(indexOfRow)],Number(indexOfRow));
					$('#table_3_th_' + indexOfRow).html(h);
					t.listenGrid_3();
				}
			});


			layui.laydate.render({
				elem: '.eoriPassTime',
				type: 'date',
				done: function(value, date, endDate){
					var indexOfRow =  $(this.elem).attr('data-index');
					t.c.data3[indexOfRow].eoriPassTime = value;
					var h = t.loadTableTdOfTbody_3(t.c.data3[Number(indexOfRow)],Number(indexOfRow));
					$('#table_3_th_' + indexOfRow).html(h);
					t.listenGrid_3();
				}
			});
			layui.laydate.render({
				elem: '.packPassTime',
				type: 'date',
				done: function(value, date, endDate){
					var indexOfRow =  $(this.elem).attr('data-index');
					t.c.data3[indexOfRow].packPassTime = value;
					var h = t.loadTableTdOfTbody_3(t.c.data3[Number(indexOfRow)],Number(indexOfRow));
					$('#table_3_th_' + indexOfRow).html(h);
					t.listenGrid_3();
				}
			});

			//多文件上传
			t.listenFormOfFileMultyBySon(3);
			// 表单控件重新加载
			form.render();
		},
		//确定删除
		delYes:function(spId,checkedIndexList,delType){
			var t = this;
			var c = this.c;
			var loadIndex = layer.load(2);
			var urlStr = '';
			if(delType==1){
				urlStr = 'toDelItemByVps';
			}else if(delType==2){
				urlStr = 'toDelItemByCompanyBrand';
			}else{
				urlStr = 'toDelItemByCompanyEuropeTrade';
			}
			$.ajax({
				url: '/api/inter/thrOperateCompanyApply/'+urlStr,
				data: "list="+spId,
				type: 'POST',
				async: true,
				success: function (result) {
					if(result.code==0){
						layer.close(loadIndex);
						layer.msg("操作成功", {icon: 1});
						var newData = [];
						var oldData = [];
						if(delType==1){
							oldData = c.data;
						}else if(delType==2){
							oldData = c.data2;
						}else{
							oldData = c.data3;
						}
						for (var i = 0; i < oldData.length; i++) {
							var isDel = false;
							for (var j = 0; j < spId.length; j++) {
								if(oldData[i].id==spId[j]){
									isDel = true;
								}
							}
							if(!isDel){
								newData.push(oldData[i]);
							}
						}
						if(delType==1){
							c.data = newData;
						}else if(delType==2){
							c.data2 = newData;
						}else{
							c.data3 = newData;
						}
						$('#' + c.id).empty();
						return t.reload(c);
					}else {//失败
						layer.close(loadIndex);
						layer.msg(result.msg, {icon: 2});
					}
				},
				error: function () {
					layer.close(loadIndex);
					layer.msg("删除失败，请稍后再试！", {icon: 2});
				}
			});
		},

		removeRow:function(index) { // 重新加载表格
			var t = this;
			t.c.data.splice(index, 1);
			return t.reload(t.c);
		},
		getData:function () {
			var vpsList = this.c.data;
			var brandList = this.c.data2;
			var europeTradeList = this.c.data3;
			return {'vpsList':vpsList, 'brandList':brandList, 'europeTradeList':europeTradeList};
		},
		init:function (c) {this.f(c);this.load();return object;},
		reload:function (c) {
			c.data = this.c.data;
			c.data2 = this.c.data2;
			c.data3 = this.c.data3;
			$('#' + this.c.id).empty();
			return this.init(c);
		},
		addRow:function (row) {
			var c = this.c;
			var t = this;
			c.data.push(row);
			var h =  `<tr id="table_th_`+(c.data.length-1)+`">`;
			h += t.loadTableTdOfTbody(row,c.data.length-1);
			h+= `</tr>`;
			$('#tbody').append(h);
			t.listenGrid_1();
		},
        addRow2:function (row) {
			var c = this.c;
			var t = this;
			c.data2.push(row);
			var h = `<tr id="table_2_th_`+(c.data2.length-1)+`">`
			+ t.loadTableTdOfTbody_2(row,c.data2.length-1)
			+ `</tr>`;
			$('#tbody_2').append(h);
			t.listenGrid_2();
        },
		addRow3:function (row) {
			var c = this.c;
			var t = this;
			c.data3.push(row);
			var h = `<tr id="table_3_th_`+(c.data3.length-1)+`">`
				+ t.loadTableTdOfTbody_3(row,c.data3.length-1)
				+ `</tr>`;
			$('#tbody_3').append(h);
			t.listenGrid_3();
		},
		addRows:function (rows) {
			var c = this.c;
			for (var i = 0; i < rows.length; i++) {
				c.data.push(rows[i]);
			}
			$('#' + c.id).empty();
			return this.reload(c);
		},
		editRow:function (index, row) {
			var c = this.c;
			c.data[index] = row;
			$('#' + c.id).empty();
			return this.reload(c);
		},
		editRowOfAttr:function (index, row) {
			var c = this.c;
			for(var key in row){
				c.data[index][key] = row[key]
			}
			$('#' + c.id).empty();
			return this.reload(c);
		},
		reloadRows:function (rows) {
			var c = this.c;
			c.data = rows;
			return this.reload(c);
		},
		//单选弹出框返回
		matchValuesAfterModalSelectRadio:function(colCode, data, extraData) {
			console.log('选择的',data);
			console.log('extraData',extraData);
			var t = this;
			// 选择国家
			if(extraData.useIn == 'countryNameByBrand') {
				t.c.data2[colCode].countryCode = data.code;
				t.c.data2[colCode].countryName = data.name;
				var h = t.loadTableTdOfTbody_2(t.c.data2[Number(colCode)],Number(colCode));
				$('#table_2_th_' + colCode).html(h);
				t.listenGrid_2();
        	}
			if(extraData.useIn == 'chooseCountryName2') {
				t.c.data3[colCode].countryCode = data.code;
				t.c.data3[colCode].countryName = data.name;
				var h = t.loadTableTdOfTbody_3(t.c.data3[Number(colCode)],Number(colCode));
				$('#table_3_th_' + colCode).html(h);
				t.listenGrid_3();
			}
			if(extraData.useIn == 'chooseCountryName3') {
				t.c.data3[colCode].eoriCountryCode = data.code;
				t.c.data3[colCode].eoriCountryName = data.name;
				var h = t.loadTableTdOfTbody_3(t.c.data3[Number(colCode)],Number(colCode));
				$('#table_3_th_' + colCode).html(h);
				t.listenGrid_3();
			}
		},
		//多文件上传
		listenFormOfFileMultyBySon:function (dateType) { // 添加监听-多文件框
			var t = this;
			var domForm = $('#' + t.c.id_form);
			var domTable = $('#' + t.c.id_grid_1);
			if(dateType=='2'){
				domForm = $('#' + t.c.id_form_2);
				domTable = $('#' + t.c.id_grid_2);
			}else if(dateType=='3'){
				domForm = $('#' + t.c.id_form_3);
				domTable = $('#' + t.c.id_grid_3);
			}



			//先移除监听、再添加监听
			//$("input").off("click");
			domTable.find('input[data-filter="_filter_input_file_multy_son"]').off("click");
			// 初始化多文件上传控件
			domTable.find('input[data-filter="_filter_input_file_multy_son"]').on('click',function (e) {
				var dom = this;
				var indexOfRow = $(this).attr('data-index');
				var sourceSon = $(this).attr('data-source-son');
				//多文件上传
				var fileCount = '';
				if(sourceSon=='2'){
					fileCount = t.c.data2[indexOfRow].otherFile!=undefined?t.c.data2[indexOfRow].otherFile:"0个附件";
				}else{
					fileCount = t.c.data3[indexOfRow].otherFile!=undefined?t.c.data3[indexOfRow].otherFile:"0个附件";
				}

				var sourceId = $(this).attr('data-source-id');
				var sourceType = $(this).attr('data-source-type');
				var sourceCode = $(this).attr('data-source-code');
				var where = {
					sourceId: sourceId,
					sourceType: sourceType,
					sourceCode: sourceCode
				}
				if (sourceId == 'undefined' || sourceId == null || sourceId == 'null') {
					alert('表单尚未保存，无法操作上传');
					return;
				}

				t.c.id_modal_multy_file_panel = 'id_modal_multy_file_panel_' + (new Date().getTime()); // 生成容器ID
				t.c.id_modal_multy_file_grid = 'id_modal_multy_file_grid_' + (new Date().getTime()); // 生成表格ID
				var content =
					`<div class="ysui-col" style="width: 100%;" id="` + t.c.id_modal_multy_file_panel + `">`
					+ `<table class="layui-hide" id="` + t.c.id_modal_multy_file_grid + `" lay-filter="` + t.c.id_modal_multy_file_grid + `"></table>`
					+ `<script type="text/html" id="templet_index_no">`
					+ `{{d.LAY_TABLE_INDEX+1}}`
					+ `</script>`
					+ `<script type="text/html" id="_multy_file_grid_toolbar">`
					+ `<div class="layui-btn-container">`;
				if(t.c.onProcessBySon == 0 && t.c.onProcess == 0) {//可编辑
					content += `<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="_multy_file_to_add"><i class="iconfont icon-add-btn"></i>新增</a>`
						+ `<a class="layui-btn layui-btn-normal layui-btn-sm layui-btn-danger" lay-event="_multy_file_batch_delete"><i class="iconfont icon-delete"></i>删除</a>`;
				}
				content += `</div>`
					+ `</script>`
					+ `<script type="text/html" id="templet_script_for_multy_file">`
					+ `<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="_multy_file_single_download"><i class="layui-icon layui-icon-download-circle" title="下载"></i></a>`;
				if(t.c.onProcessBySon == 0 && t.c.onProcess == 0) {//可编辑
					content += `<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="_multy_file_single_delete"><i class="layui-icon layui-icon-close" title="删除"></i></a>`;
				}
				content += `</script>`
					+ `</div>`;
				// + t.loadScriptTPL();

				var w=($(window).width()*0.8);
				var h=($(window).height() - 50);
				layer.open({
					type: 1,
					area: [w + 'px', h + 'px'],
					fix: false,
					//不固定
					maxmin: true,
					shade: 0.6,
					title: '附件列表',
					content: content,
					btn: ['确定', '关闭'],
					//点击弹层外区域关闭
					shadeClose: true,
					yes: function (index) {// 点击“确定”，执行的回调函数
						layer.close(index);
						//多文件上传
						if(sourceSon=='2'){
							t.c.data2[indexOfRow].otherFile = fileCount;
							var h = t.loadTableTdOfTbody_2(t.c.data2[Number(indexOfRow)],Number(indexOfRow));
							$('#table_2_th_' + indexOfRow).html(h);
							t.listenGrid_2();
						}else{
							t.c.data3[indexOfRow].otherFile = fileCount;
							var h = t.loadTableTdOfTbody_3(t.c.data3[Number(indexOfRow)],Number(indexOfRow));
							$('#table_3_th_' + indexOfRow).html(h);
							t.listenGrid_3();
							console.log('t.c.data3',t.c.data3);
						}
					},
					btn2: function(index, layero){
						layer.close(index);
					},
					success: function(layero, index) {
						layui
							.use(['form', 'table'], function(){
								var table = layui.table;
								var form = layui.form;
								var $ = layui.jquery;

								// 创建渲染实例
								table.render({
									elem: '#' + t.c.id_modal_multy_file_grid
									,url: '/api/inter/tbFileInfo/search'
									,toolbar: '#_multy_file_grid_toolbar'
									,defaultToolbar: [{
										title: '刷新页面'
										,layEvent: 'LAYTABLE_REFRESH'
										,icon: 'layui-icon-refresh'
									}]
									,height: 'full-240' // 最大高度减去其他容器已占有的高度差
									,limit : 50
									,limits : [50,100,200,500]
									,where: where
									,cellMinWidth: 150
									,page: true
									,request: {
										pageName: 'page',
										limitName: 'size'
									}
									,even: false // 开启隔行背景
									,cols: [ [
										{'title': '', 'type': 'checkbox', 'fixed': 'left', 'unresize': true, 'width': '70'},
										{'title': '文件名', 'field': 'preName', 'width': '180', 'align': 'center'},
										{'title': '大小', 'field': 'fileSize', 'width': '80', 'align': 'center'},
										{'title': '类型', 'field': 'sufName', 'width': '120', 'align': 'center'},
										{'title': '上传时间', 'field': 'createTime', 'width': '200', 'align': 'center'},
										{'title': '操作', 'field': 'ope', 'width': '240', 'align': 'center', templet: '#templet_script_for_multy_file'}
									] ]
									,done: function(objDone){
										$(dom).val(objDone.count + '个附件');
										fileCount = objDone.count + '个附件';
										// 绑定新增按钮-文件上传控件
										$('#' + t.c.id_modal_multy_file_panel).find('a[lay-event="_multy_file_to_add"]').each(function(index, domEle){
											var dom = this;
											var labelName = $(this).attr('label');
											layui.upload.render({
												elem: dom,
												url: t.c.urlUpload,
												multiple: true,
												accept: 'file',
												progress: function(n, elem){
													//dom.val(n + '%');
												},
												done: function(res, index, upload){
													if (res.code == 0) {
														console.log('res:',res);
														var fileName = res.data.fileName;
														var indexPeriod = fileName.indexOf('.');

														// 添加数据到附件表
														$.ajax({
															type: "POST",
															url: '/api/inter/tbFileInfo/add',
															data: {
																sourceType: sourceType,
																sourceId: sourceId,
																sourceCode: sourceCode,
																preName: indexPeriod >= 0 ? fileName.substring(0, indexPeriod) : fileName,
																sufName: indexPeriod >= 0 ? fileName.substring(indexPeriod + 1, fileName.length) : '',
																fileType: res.data.fileType,
																fileSize: res.data.fileSizeLong,
																filePath: res.data.filePath
															},
															success: function (data) {
																if (data.code == 0) {
																} else {
																	alert(data.msg);
																}
															}
														});
														return;
														var urlFile = res.data.filePath;
														domForm.find('img[label="' + labelName +'"]').attr('src', '/static/img/img_file.jpg');
														domForm.find('input[name="' + labelName +'"]').val(urlFile);
														domForm.find('button[label="' + labelName +'"]').show();
													}
												},
												allDone: function(obj){
													setTimeout(function(){
														layui.table.reload(t.c.id_modal_multy_file_grid, {
															page: {curr: 1},
															where: where
														});
													}, 1000);
												}
											});
										});
									}
									,error: function(res, msg){
										console.log(res, msg)
									}
								});
							});

						// 右侧工具栏事件
						layui.table.on('toolbar(' + t.c.id_modal_multy_file_grid + ')', function(obj){
							var id = obj.config.id;
							var checkStatus = layui.table.checkStatus(id);
							var datas = checkStatus.data;
							var othis = lay(this);

							switch(obj.event){
								case '_multy_file_batch_delete':
								{
									if(datas.length == 0) {
										layer.alert('尚未选中数据');
									} else {
										var ids = '';
										for(var i = 0 ;i < datas.length; i++){
											ids += datas[i].id + ',';
										}
										var indexOfLoading = layer.load(1, {
											shade: [0.5,'#000000'] //0.1透明度的白色背景
										});
										$.ajax({
											type: "POST",
											url: '/api/inter/tbFileInfo/deleteBatch',
											data: {ids: ids.substring(0, ids.length - 1)},
											success: function (res) {
												if (res.code == 0) {
													layer.msg(res.msg);
													layui.table.reload(t.c.id_modal_multy_file_grid,{
														page: {curr: 1},
														where: where
													})
												} else {
													alert(res.msg);
												}
												layer.close(indexOfLoading);
											}
										});
									}
									break;
								}
							};
						});

						// 表格内按钮点击事件
						layui.table.on('tool(' + t.c.id_modal_multy_file_grid + ')', function(obj){
							console.log(obj);
							switch(obj.event){
								case '_multy_file_single_download':
								{
									const xhr = new XMLHttpRequest();
									xhr.open('GET', obj.data.filePath);
									xhr.responseType = 'blob';
									xhr.onload = function() {
										const blob = xhr.response;
										const link = document.createElement('a');
										link.href = URL.createObjectURL(blob);
										link.download = obj.data.preName + (obj.data.sufName ? '.' + obj.data.sufName : '');
										link.target = "_blank"; // 可选，如果希望在新窗口中下载文件，请取消注释此行
										link.click();
									};
									xhr.send();
									layer.close(indexOfLoading);
									break;
								}
								case '_multy_file_single_delete':
								{
									layer.confirm('确定删除此附件？ ', {
										btn: ['确定','取消'] //按钮
									}, function(index){
										var indexOfLoading = layer.load(1, {
											shade: [0.5,'#000000'] //0.1透明度的白色背景
										});
										$.ajax({
											type: "POST",
											url: '/api/inter/tbFileInfo/delete',
											data: {id: obj.data.id},
											success: function (res) {
												if (res.code == 0) {
													layer.msg(res.msg);
													layui.table.reload(t.c.id_modal_multy_file_grid,{
														page: {curr: 1},
														where: where
													})
												} else {
													alert(res.msg);
												}
												layer.close(indexOfLoading);
											}
										});
									}, function(index){
										layer.close(index);
									});
									break;
								}
							};
						});
					}
				});
			});
		},
	};
	exports('simple_table_THR_OperateCompanyApply_ByArchives', object);
});